<%@page import="cn.jussi.mydbutils.MyDBUtils"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.Connection"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
</head>
<body>

	<%
		String id = request.getParameter("id");
			String sql = null;
			if("all".equals(id))
		sql = "select * from users";
			else
		sql = "select * from users where id="+id;
		
			Connection conn = null;
			Statement stat = null;
			ResultSet rs = null;
			
			try {
		conn = MyDBUtils.getConnection();
		stat = conn.createStatement();
		rs = stat.executeQuery(sql);
		if(!rs.next())
			out.println("此用户不存在！");
		else{
			int sql_id = rs.getInt("id"); 
			String username = rs.getString("username");
			String phoneNum = rs.getString("phone_num");
			String address = rs.getString("address");
			String regDate = rs.getString("reg_date").toString();
			out.println(sql_id+"-----"+username+"-----"+phoneNum+"-----"+address+"-----"+regDate);
	%><br>
			<%
				}
				
				while(rs.next()){
					int sql_id = rs.getInt("id"); 
					String username = rs.getString("username");
					String phoneNum = rs.getString("phone_num");
					String address = rs.getString("address");
					String regDate = rs.getString("reg_date").toString();
					out.println(sql_id+"-----"+username+"-----"+phoneNum+"-----"+address+"-----"+regDate);
			%><br>
			<%
				}
				
					} catch(Exception e) {
				e.getStackTrace();
					} finally {
				MyDBUtils.close(conn, stat, rs);
					}
			%>
	
</body>
</html>